/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.base.common.util.collection;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

/**
 * 由于Apache-common的类不支持泛型，因此单独提出进行处理。<br>
 * Defines a map that holds a collection of values against each key.
 * <p>
 * A <code>MultiMap</code> is a Map with slightly different semantics. Putting a
 * value into the map will add the value to a Collection at that key. Getting a
 * value will return a Collection, holding all the values put to that key.
 * <p>
 * For example:
 * 
 * <pre>
 * MultiMap mhm = new MultiHashMap();
 * mhm.put(key, &quot;A&quot;);
 * mhm.put(key, &quot;B&quot;);
 * mhm.put(key, &quot;C&quot;);
 * Collection coll = (Collection) mhm.get(key);
 * </pre>
 * <p>
 * <code>coll</code> will be a collection containing "A", "B", "C".
 * <p>
 * NOTE: Additional methods were added to this interface in Commons Collections
 * 3.1. These were added solely for documentation purposes and do not change the
 * interface as they were defined in the superinterface <code>Map</code> anyway.
 * 
 * @since Commons Collections 2.0
 * @version $Revision: 7 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr
 *          2008) $
 * 
 * @author Christopher Berry
 * @author James Strachan
 * @author Stephen Colebourne
 * @author yanjiaqiang
 */
public interface MultiMap<K, V> extends Map<K, Collection<V>>, Serializable {

	/**
	 * 删除掉key的值集合中的item
	 * 
	 * @param key
	 * @param item
	 * @return 如果key对应的集合不为null并且c.remove(item)成功时，返回item.
	 */
	public V removeItem(K key, V item);

	/**
	 * 判断key对应的集合是否存在该item的值
	 * 
	 * @param key
	 * @param value
	 * @return
	 */
	boolean containsItemValue(K key, V item);

	/**
	 * 将item放入key对应的集合中，如果该集合为null，则新建该集合
	 * 
	 * @param key
	 * @param item
	 * @return
	 */
	boolean putItem(K key, V item);

	/**
	 * 所有集合值放在一个集合中返回
	 * 
	 * @return
	 */
	Collection<V> itemValues();

}
